home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / HYP / C-D / DartmouthXCMDs.cpt / Dartmouth XCMDs Vol 1&2 / card_6552.txt < prev    next >
Text File  |  1989-02-26  |  3KB  |  140 lines

  1. -- card: 6552 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 3241
  5. -- name: 
  6.  
  7.  
  8. -- part 1 (field)
  9. -- low flags: 80
  10. -- high flags: 0007
  11. -- rect: left=12 top=26 right=298 bottom=491
  12. -- title width / last selected line: 0
  13. -- icon id / first selected line: 0 / 0
  14. -- text alignment: 0
  15. -- font id: 22
  16. -- text size: 10
  17. -- style flags: 0
  18. -- line height: 13
  19. -- part name: Source
  20.  
  21.  
  22. -- part 2 (button)
  23. -- low flags: 00
  24. -- high flags: A003
  25. -- rect: left=314 top=300 right=322 bottom=435
  26. -- title width / last selected line: 0
  27. -- icon id / first selected line: 0 / 0
  28. -- text alignment: 1
  29. -- font id: 0
  30. -- text size: 12
  31. -- style flags: 0
  32. -- line height: 16
  33. -- part name: Show LSP Source
  34. ----- HyperTalk script -----
  35. on mouseUp
  36.   set the visible of card field 1 to not the visible of card field 1
  37.   if the visible of card field 1 is true then
  38.     set the name of me to "Hide LSP Source"
  39.   else set the name of me to "Show LSP Source"
  40. end mouseUp
  41.  
  42.  
  43.  
  44. -- part contents for background part 16
  45. ----- text -----
  46. LASTPATHCOMPONENT XFCN version 1.0
  47. March 17, 1988
  48. Kevin Calhoun
  49.  
  50. LastPathComponent takes a pathname and returns the last component of it.  The last component is the string of characters following the last colon in the pathname.
  51.  
  52. Examples:
  53.  
  54. put LastPathComponent("HD:My Best Years:1962:The Drive-In")  
  55.    --puts The Drive-In into the message box.
  56.  
  57. put LastPathComponent("Winkin:Blinkin:Nod") into theContainer
  58.    --puts Nod into theContainer
  59.  
  60. -- part contents for card part 1
  61. ----- text -----
  62. UNIT LastPathComponent;
  63. { LastPathComponent XFCN ¬©1988 by the Trustees of Dartmouth College. }
  64. { Written by John K. Calhoun, Courseware Development. }
  65.  
  66. INTERFACE
  67.   USES
  68.     XCMDIntf;
  69.  
  70.   PROCEDURE Main (paramPtr : XCMDPtr);
  71.  
  72. IMPLEMENTATION
  73.  
  74.   PROCEDURE DoJsr (addr : ProcPtr);
  75.   INLINE
  76.     $205F, $4E90;
  77.  
  78.   PROCEDURE ZeroToPas (paramPtr : XCmdPtr;
  79.                   zeroStr : Ptr;
  80.                   VAR pasStr : Str255);
  81.   BEGIN
  82.     WITH paramPtr^ DO
  83.       BEGIN
  84.         inArgs[1] := ORD(zeroStr);
  85.         inArgs[2] := ORD(@pasStr);
  86.         request := xreqZeroToPas;
  87.         DoJsr(entryPoint);
  88.       END;
  89.   END;
  90.  
  91.   FUNCTION PasToZero (paramPtr : XCmdPtr;
  92.                   str : Str255) : Handle;
  93.   BEGIN
  94.     WITH paramPtr^ DO
  95.       BEGIN
  96.         inArgs[1] := ORD(@str);
  97.         request := xreqPasToZero;
  98.         DoJsr(entryPoint);
  99.         PasToZero := Handle(outArgs[1]);
  100.       END;
  101.   END;
  102.  
  103.   PROCEDURE GetLPC (paramPtr : XCMDPtr);
  104.     VAR
  105.       fullPathName : Str255;
  106.       fileName : Str255;
  107.  
  108.     FUNCTION AfterLastColon (str : Str255) : Str255;
  109.       VAR
  110.         theLength, index : INTEGER;
  111.     BEGIN
  112.       theLength := LENGTH(str);
  113.       index := theLength;
  114.       IF POS(':', str) > 0 THEN
  115.         BEGIN
  116.           WHILE (str[index] <> ':') DO
  117.             BEGIN
  118.               index := index - 1;
  119.             END;
  120.           AfterLastColon := COPY(str, index + 1, theLength - index);
  121.         END
  122.       ELSE
  123.         AfterLastColon := str;
  124.     END;
  125.  
  126.   BEGIN
  127.     IF paramPtr^.paramCount > 0 THEN
  128.       BEGIN
  129.         ZeroToPas(paramPtr, paramPtr^.params[1]^, fullPathName);
  130.         fileName := AfterLastColon(fullPathName);
  131.         paramPtr^.returnValue := PasToZero(paramPtr, fileName);
  132.       END;
  133.   END;
  134.  
  135.   PROCEDURE Main;
  136.   BEGIN
  137.     GetLPC(paramPtr);
  138.   END;
  139.  
  140. END.